Repository navigation
Capture: a deadline per shot so a hung renderer can't hang the run - #61
Merged
Merged
Conversation
One hung page call (an evaluate on a wedged renderer, a hook that never resolves) blocked the worker forever: no row, no report, no exit. Each capture attempt now races a 120s deadline (RENDERDIFF_SHOT_TIMEOUT seconds). On expiry the page is closed and replaced in the same context, and the shot throws a TimeoutError naming the step, which the existing retry-once and error path handle. Fixes #54 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… test deadline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Each capture attempt in
shoot()now races a 120s deadline. On expiry the page is closed and replaced with a fresh,prepare()d page in the same context, and the shot throwserrors.TimeoutError("timeout after 120s at <step> on <side>").transient()already retriesTimeoutError, so it gets the existing retry-once, then the existing error path: anERRORrow,results.json, the report's errors list, exit 3.src/capture.ts: a page-keyedstepWeakMap, the same pattern asnetwork.capture()sets it toload,before hook,settleorscreenshot, so the error says where it stuck.src/run.ts: the worker keeps its two pages in a mutablepagesholder, so locate/masks/snapshot and the next job use the replacement page. A deadline hit in thebefore hookstep throws aHookErrorinstead, so a hook that may have half-run is never retried, as for a hook that throws.Why
Only
gotohad a timeout.addStyleTag, everypage.evaluate, thebeforehook andscreenshothad none, and the in-page timer races can't fire while the renderer's main thread is wedged. One hung call blockedPromise.allSettledin the worker forever. Nothing was printed or written, and the process never exited.Deviations from the issue
routeFromHARupdate: truerecording, and a recreated context would overwrite that part file and lose the earlier shots' entries. It would also mean redoing storageState and the routes. The close is awaited becausepage.clockbelongs to the context, so a page still closing would break the replacement'sclock.install.RENDERDIFF_SHOT_TIMEOUT(seconds, default 120; a missing, zero, negative or non-numeric value falls back to 120), not a config field. The regression test needs a short deadline. A config field would need validation,configHashand config-shape docs. It also gives a user with a very slow page a way to raise the limit, and it's documented indocs/how-it-works.mdand the skill's Errors table.Testing
tests/fixtures/pages/hang: aMutationObserveron<head>busy-loops on renderdiff's first injected<style>, soaddStyleTagnever returns. It's deterministic and needs no timers.shot deadlineintests/visual/guardrails.test.ts. It runs/hangthen/homeat concurrency 1 withRENDERDIFF_SHOT_TIMEOUT=5(headroom for/homeon a loaded CI runner), and checks for exit 3, one error matchingtimeout after 5s at settle on left, and/homecomparing identical on the same worker (which proves the replacement page works). A second test gives/menuabeforehook that never resolves and checks fortimeout after 2s at before hook on leftwith no retry (2 hits, one per side).renderdiff timed outat the 60s harness limit. With the fix the two tests take about 15s.npm run typecheck,npm run lint,npm run format:check,npm test(290/290) andnpm run test:visual(329/329) all pass.Fixes #54
🤖 Generated with Claude Code